/**
 * Created by 000188 on 2016/6/27.
 */
import React from 'react';
import Ajax from 'superagent';
var Logo = require('logo');
var Rule = require('rule-btn');
var Btn = require('btn');
var Act = require('act');
var Content = require('content');
var CollarWelfare = require('user-form');
var MobileForm = require('mobile-form');

var Index = React.createClass({
    render(){
        return <div>
            <Logo src="../../images/logo.png" width="100%"/>
            <Rule />
            <div style={{'textAlign':'center'}}>
                <Btn width="45%" text="我要抢红包" click={this.toScene} title="手机新会员专属"/>
                <Btn width="45%" text="我要领福利" click={this.toScene2} title="东方万里行新会员专属"/>
            </div>
            <Act list={this.state.list}/>
        </div>
    },
    toScene(){
        Content.render(<MobileForm />);
    },
    toScene2(){
        Content.render(<CollarWelfare />);
    }
    ,
    getInitialState(){
        return {
            list: []
        }
    },
    componentDidMount(){
        require(['config'], Config=> {
            Ajax.post(Config.api.user)
                .set('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8')
                .send({type:4})
                .end((err, res)=> {
                    if(err){
                        console.log(err);
                    }else{
                        this.setState({
                            list: JSON.parse(res.text).Data
                        })
                    }
                })
        })
    }
});

module.exports = Index;